package com.example.login.Mapper;

import com.example.login.Pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;

@Repository
@Mapper
public interface OrderMap {
   @Insert("INSERT INTO xtshop_order(order_id,item_id,order_status,account_intotal," +
           "account_sale,payment,create_time,address_id,user_id,num_intotal,order_tag,sku_code) " +
           "VALUES(#{order_id},#{item_id},#{order_status},#{account_intotal},#{account_sale},#{payment}," +
           "#{create_time},#{address_id},#{user_id},#{num_intotal},1,#{sku_code});")
   void insert(int order_id,int item_id,int order_status,int account_intotal,int account_sale,
                int payment,String create_time,int address_id,int user_id,int num_intotal,String sku_code);

   @Select("select * from xtshop_order where user_id=#{user_id} and order_tag=1")
   ArrayList<Order> getOrder(int user_id);
   //获取最大订单id
   @Select("SELECT MAX(order_id) FROM `xtshop_order`")
   int getMaxId();

}
